package com.colbby.datahouse.transform;


import com.colbby.datahouse.utils.CastUtils;
import com.colbby.datahouse.utils.TypeDescriptor;
import com.colbby.datahouse.utils.TypeUtils;

public class BooleanTransformer implements DataTypeTransform<Boolean> {

	public static final BooleanTransformer INSTANCE = new BooleanTransformer();
	
	@Override
	public Boolean transform(TypeDescriptor returnType, Object value) {
		return CastUtils.castToBoolean(CastUtils.getValue(value));
	}

	@Override
	public boolean shouldDo(TypeDescriptor returnType, Object value) {
		return TypeUtils.isSuperClass(Boolean.class, returnType.getTypeClass());
	}
}
